import pytest
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys


class Test_A3mall():
    @pytest.fixture()
    def driver(self):
        driver=webdriver.Edge()
        driver.maximize_window()
        driver.get('http://10.59.9.14:7003/')
        yield driver
        time.sleep(10)
        driver.quit()
    def test_01(self,driver):
        driver.find_element(By.LINK_TEXT,'登录').click()
        driver.find_element(By.NAME,'username').send_keys('18986670716')
        driver.find_element(By.NAME,'password').send_keys('a123456')
        time.sleep(10)
        driver.find_element(By.CLASS_NAME,'finish-btn').click()
        time.sleep(2)
        driver.find_element(By.XPATH,'/html/body/div[3]/div[2]/ul/li[1]/a').click()
        time.sleep(1)
        search=driver.find_element(By.CLASS_NAME,'search-input')
        search.send_keys('音乐耳机')
        search.send_keys(Keys.ENTER)
        time.sleep(3)
        driver.find_element(By.XPATH,'/html/body/div[5]/div[2]/div[2]/div[1]/ul/li/div[1]/span/a/img').click()
        driver.find_element(By.ID,'buy-cart').click()
        time.sleep(2)
        driver.find_element(By.ID,'order-button').click()
        time.sleep(5)

if __name__ == '__main__':
    pytest.main()



